using System;
using NUnit.Framework;
namespace TestsParking
{
	[TestFixture()]
	public class TestsParking
	{
		[Test()]
		public void TestConstructeur ()
		{
			Parking.Parking p = new Parking.Parking (100);
			Assert.AreEqual (0, p.nbPlacesOccupees);
			Assert.AreEqual (100, p.nbPlacesTotales);
			Assert.AreEqual (100, p.nbPlacesRestantes);
		}

		[Test()]
		public void TestNbPlacesOccupees ()
		{
			Parking.Parking p = new Parking.Parking (100);
			Assert.AreEqual (0, p.nbPlacesOccupees);
			Assert.AreEqual (p.nbPlacesTotales - p.nbPlacesRestantes, p.nbPlacesOccupees);
			Assert.GreaterOrEqual (p.nbPlacesOccupees, 0);
		}

		[Test()]
		public void TestNbPlacesTotales ()
		{
			Parking.Parking p = new Parking.Parking (100);
			Assert.AreEqual (100, p.nbPlacesTotales);
			Assert.AreEqual (p.nbPlacesTotales, p.nbPlacesRestantes + p.nbPlacesOccupees);
			Assert.GreaterOrEqual (p.nbPlacesTotales, 100);
		}
		
		[Test()]
		public void TestGarerVoiture ()
		{
			Parking.Parking p = new Parking.Parking (5);
			Assert.IsNotNull (p.garerVoiture (new Parking.Voiture()));
			Assert.AreEqual (4, p.nbPlacesRestantes);
			Assert.AreEqual (1, p.nbPlacesOccupees);
			Assert.IsNotNull (p.garerVoiture (new Parking.Voiture()));
			Assert.IsNotNull (p.garerVoiture (new Parking.Voiture()));
			Assert.IsNotNull (p.garerVoiture (new Parking.Voiture()));
			Assert.IsNotNull (p.garerVoiture (new Parking.Voiture()));
			Assert.AreEqual (0, p.nbPlacesRestantes);
			Assert.IsNull (p.garerVoiture (new Parking.Voiture()));
			Assert.AreEqual (0, p.nbPlacesRestantes);
		}
		
		[Test()]
		public void TestReprendreVoiture ()
		{
			Parking.Parking p = new Parking.Parking (5);
			Parking.Ticket t = p.garerVoiture (new Parking.Voiture());
			Assert.AreEqual (4, p.nbPlacesRestantes);
			Assert.IsNull (p.reprendreVoiture (t.numero + 1));
			Assert.AreEqual (4, p.nbPlacesRestantes);
			Assert.AreEqual (t, p.reprendreVoiture (t.numero));
			Assert.AreEqual (5, p.nbPlacesRestantes);
		}
	}
}
